package com.qiezi.project.activity;

import android.content.Intent;
import android.os.Bundle;

import com.qiezi.App;
import com.qiezi.R;
import com.qiezi.base.BaseMvpActivity;
import com.qiezi.project.contract.InitContract;
import com.qiezi.mvp.CreatePresenter;

@CreatePresenter(presenter = InitContract.Presenter.class)
public class InitialActivity extends BaseMvpActivity<InitContract.Presenter> implements InitContract.View {

    @Override
    protected int getLayoutRes() {
        return R.layout.activity_initial;
    }

    @Override
    protected void initData(Bundle saveBundle) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                int count = 0;
                while (true){
                    try {
                        Thread.sleep(3000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    if (App.getInstance().isLogin()){
                        startActivity(new Intent(InitialActivity.this,MainActivity.class));
                        finish();
                        break;
                    }else {
                        App.getInstance().download();
                        count++;
                        if (count > 2)break;
                    }
                }
            }
        }).start();
    }

    @Override
    protected void initListener() {

    }

    @Override
    public void resultData(Object data) {

    }
}
